home *** CD-ROM | disk | FTP | other *** search
/ Night Owl 6 / Night Owl's Shareware - PDSI-006 - Night Owl Corp (1990).iso / 037a / genovr.zip / GENOVR.PAS next >
Pascal/Delphi Source File  |  1991-08-18  |  3KB  |  99 lines

  1. {$F+,I-,O-,N-}
  2. {$IFDEF PROD } {$D-,L-,R- } {$ELSE } {$D+,L+,R+ } {$ENDIF }                     {.L-}
  3.                                                                                 {.L+}
  4. (*     Free distribution
  5.  *
  6.  *     This unit may be distributed and used freely. No donations are 
  7.  *     solicited. Comments may be E-mailed via BITNET/INTERNET to:
  8.  *                SPRAGGEJ@QUCDN.QUEENSU.CA
  9.  *
  10.  *     This file may be modified and distributed, as long as the
  11.  *     copyright notice is not removed, and the modifications are 
  12.  *     documented.
  13.  *
  14.  *     Disclaimer: this unit is provided as is, without warranty of any 
  15.  *     kind. Use it at your own risk. 
  16.  *
  17.  *)
  18.  
  19. (*           E X T E N D E D   P R O G R A M   S U P P O R T
  20.  *
  21.  *                            Overlay Buffer Sizing
  22.  *
  23.  *     Written:    90.06.10
  24.  *     Modified:
  25.  *     Status:     Source confidential, trade secret
  26.  *
  27.  *     Open the overlay file, prepare to access overlays, and if no
  28.  *     extended memory is available for overlay swaps, increase the 
  29.  *     size of the overlay buffer as much as possible.
  30.  *
  31.  *     Notes:  Programs which include this unit will not run under 
  32.  *             versions of DOS earlier than 3.0.
  33.  *
  34.  *             A compile time flag is supported in this module:
  35.  *             PROD     indicates this is a production version of the
  36.  *                      program, and a number of run-time tests are no
  37.  *                      longer necessary.
  38.  *
  39.  *     Copyright (c) 1991 by Taliesin Software Resources (Ontario) Limited
  40.  *     All rights reserved
  41.  *)
  42.  
  43. UNIT GENOVR;
  44.  
  45. INTERFACE
  46.  
  47. USES   OVERLAY,                   { TURBO (tm) overlay manager unit    }
  48.        DOS;                       { extended Pascal support            }
  49.  
  50. IMPLEMENTATION 
  51.  
  52. FUNCTION OvrName : STRING;        { return the overlay name            }
  53.  
  54. VAR
  55.    ofd     :   DirStr;                      { overlay file directory   }
  56.    ofb     :   NameStr;                     { overlay base name        }
  57.    ofx     :   ExtStr;                      { program extension (.EXE) }
  58.  
  59. BEGIN          { Overlay Name }
  60.    IF ParamStr (0) = '' THEN
  61.    BEGIN
  62.        WRITELN ('You must have DOS version 3 or over to run this',
  63.                 ' program.');
  64.        RunError (1000);
  65.    END;
  66.    FSplit (ParamStr (0), ofd, ofb, ofx);
  67.    OvrName := ofd + ofb + '.OVR'
  68. END;           { Overlay Name }
  69.  
  70. PROCEDURE  IncreaseBuffer              { increase overlay buffer size  }
  71. (
  72.        ofn              :    STRING;        { overlay file name        }
  73.        minfree          :    LONGINT        { minimum free allowed     }
  74. );
  75.  
  76. VAR
  77.    size                 :    LONGINT;       { size of the buffer       }
  78.    ofl                  :    FILE;          { overlay file for length  }
  79.  
  80. BEGIN          { Increase Buffer }
  81.    ASSIGN (ofl, ofn);
  82.    RESET (ofl, 1);
  83.    size := FileSize (ofl);
  84.    CLOSE (ofl);
  85.    IF size > MaxAvail - minfree THEN
  86.        size := MaxAvail - minfree;
  87.    IF (size > OvrGetBuf) THEN
  88.        OvrSetBuf (size)
  89. END;           { Increase Buffer }
  90.  
  91. BEGIN          { Initialization section }
  92.    OvrInit (OvrName);
  93.    IF OvrResult <> 0 THEN
  94.        RunError (OvrResult);
  95.    OvrInitEMS;
  96.    IF (OvrResult <> 0) THEN 
  97.        IncreaseBuffer (OvrName, 65536);
  98. END.           { Info Resource Overlay Install }
  99.